//*************************************************************************
//  RationalTester2.java     Author: Lewis/Loftus
//
//  Driver to exercise the use of  multiple Rational objects.
//*************************************************************************

public class RationalTester2 
{
   //----------------------------------------------------------------------
   // Creates some rational number objects and performs various
   // operations on them.
   //----------------------------------------------------------------------
   public static void main(String[] args)
   {
      RationalNumber2 r1 = new RationalNumber2(1, 3);
      RationalNumber2 r2 = new RationalNumber2(1, 9);
      RationalNumber2 r3, r4, r5, r6, r7;

      System.out.println("First rational number: " + r1);
      System.out.println("Second rational number: " + r2);
      if (r1.isLike(r2))
          System.out.println("r1 and r2 are equal.");
      else
          System.out.println("r1 and r2 are NOT equal.");

      if (r1.compareTo(r2) != 1 )
            System.out.println(" r1 > r2 ");
        else
            if (r1.compareTo(r2) !=-1)
            System.out.println(" r1 < r2 ");
        else
            System.out.println("r1 = r2");

      r3 = r1.reciprocal();
      System.out.println("The reciprocal of r1 is: " + r3);

      r4 = r1.add(r2);
      r5 = r1.subtract(r2);
      r6 = r1.multiply(r2);
      r7 = r1.divide(r2);

      System.out.println("r1 + r2: " + r4);
      System.out.println("r1 - r2: " + r5);
      System.out.println("r1 * r2: " + r6);
      System.out.println("r1 / r2: " + r7);

   }
}
